﻿using System;
using System.Collections.Generic;
using System.Linq;
using YunZuan.Models.Attributes;
using YunZuan.Models.Entities;

namespace YunZuan.Models
{
    [Table(TableName = "yz_cart", PrimaryKey = "CartID")]
    public class Cart : BaseEntity
    {
         
        private int _cartid;
        /// <summary>
        ///购物车ID
        /// </summary>
        [Column(IsAutoIncrement = true)]
        public int CartID
        {
            get { return _cartid; }
            set { this.ChangeNotify<int>("CartID", value, ref _cartid); }
        }
        private int _customerid;
        /// <summary>
        ///客户ID
        /// </summary>
        public int CustomerID
        {
            get { return _customerid; }
            set { this.ChangeNotify<int>("CustomerID", value, ref _customerid); }
        }
        private int _userid;
        /// <summary>
        ///团队ID
        /// </summary>
        public int UserID
        {
            get { return _userid; }
            set { this.ChangeNotify<int>("UserID", value, ref _userid); }
        }
        private int _goodsID;
        /// <summary>
        ///商品ID
        /// </summary>
        public int GoodsID
        {
            get { return _goodsID; }
            set { this.ChangeNotify<int>("GoodsID", value, ref _goodsID); }
        }
        private decimal? _inventorycount = 1;
        /// <summary>
        ///商品数量
        /// </summary>
        public decimal? InventoryCount
        {
            get { return _inventorycount; }
            set { this.ChangeNotify<decimal?>("InventoryCount", value, ref _inventorycount); }
        }


        private int _carttype;
        /// <summary>
        ///购物车类型
        /// </summary>
        public int CartType
        {
            get { return _carttype; }
            set { this.ChangeNotify<int>("CartType", value, ref _carttype); }
        }
        private DateTime _createtime;
        /// <summary>
        ///加入时间
        /// </summary>
        public DateTime CreateTime
        {
            get { return _createtime; }
            set { this.ChangeNotify<DateTime>("CreateTime", value, ref _createtime); }
        }
        private int _goodstypeid;
        /// <summary>
        ///商品类型
        /// </summary>
        public int GoodsTypeID
        {
            get { return _goodstypeid; }
            set { this.ChangeNotify<int>("GoodsTypeID", value, ref _goodstypeid); }
        }
        public string InventoryIDs { get; set; }
        int[] inventoryIDArray;
        public int[] InventoryIDArray
        {
            get
            {
                if (InventoryIDs != null&&InventoryIDs != "")
                {
                    inventoryIDArray = InventoryIDs.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(Int32.Parse).ToArray();
                }
                return inventoryIDArray;
            }
            set
            {
                inventoryIDArray = value;
            }
        }

        public class CartList<T>
        {
            private string GoodsTypeName { get; set; }
            private List<T> InventoryList { get; set; }
        }
    }
}
